package com.study.thread.createThread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class CallableDemo3 {
    public static void main(String[] args) {
        FutureTask future = new FutureTask(new ThreadDemoTest2());
        try {
            future.run();
            Integer r = (Integer) future.get();
            System.out.println("返回参数：" + r);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class ThreadDemoTest2 implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println("执行Callable，带返回参数的创建线程");
        boolean f = true;
        while (f) {
            Thread.sleep(2000);
            f = false;
        }
        return 1 + 1;
    }
}
